import { Injectable } from '@nestjs/common';
import { EcfoodModel } from "../Scheam/echartfood.scheam"

@Injectable()
export class EcfoodService {

  async creat(year: number, quarter: string, type: string) {
    return await EcfoodModel.create({ year, quarter, type, count: 1 });

  }

  async findfood(year: number, quarter: string, type: string) {
    return await EcfoodModel.findOneAndUpdate({ year, quarter, type }, {
      $inc: { count: 1 }
    });
  }
  async getdata(year: number) {
    return await EcfoodModel.find({
      year
    }).sort({ "quarter": "asc" })
  }
}
